Strict

Import agfx

Global myTmpScreen:TTmpScreen

Class TAgfx_test_app Extends TFramework

	Method OnCreate:Int()
		
		Super.OnCreate()
				
		myTmpScreen = New TTmpScreen		
		myTmpScreen.Prepare()
		
		Return 0
	End
	
End


Class TTmpScreen Extends TScreen
	
	Field polygon:TPolygon
	Field a:Float=0
	' START when app is created
	Method Start:Void()
	
		Self.polygon = New TPolygon()
		
		Self.polygon.AddPoint(New TVector2(30,30))
		Self.polygon.AddPoint(New TVector2(50,10))
		Self.polygon.AddPoint(New TVector2(60,30))
		Self.polygon.AddPoint(New TVector2(50,60))
		Self.polygon.AddPoint(New TVector2(40,60))
	
		
		Print(Self.polygon.ToString())
		
	End
	
	' main app logic loop update
	Method Update:Void()
	
		Self.polygon.Update()
		
		If KeyDown(KEY_UP) Then Self.polygon.SetOffset(0,-1)
		If KeyDown(KEY_DOWN) Then Self.polygon.SetOffset(0,1)
		If KeyDown(KEY_LEFT) Then Self.polygon.SetOffset(-1,0)
		If KeyDown(KEY_RIGHT) Then Self.polygon.SetOffset(1,0)
		
		' rotate around point from polygon
		Self.polygon.RotateByID(3,2)
		
		' rotate around user defined point
		'Self.polygon.RotateAt(New TVector2(50,50),2)
		
		' rotate around calculated center
		'Self.polygon.Rotate(2)
		
	End
	
	' main app render loop
	Method Render:Void()
		Cls
		Self.polygon.Draw()
	End
End
